#include<iostream>
#include<unistd.h>
#include<fcntl.h>
void SetNoblocking(int fd)
{
    int fl=fcntl(fd,F_GETFL);
    if(fl<0)
    {
        perror("fcntl");
    }
    fcntl(fd,F_SETFL,fl|O_NONBLOCK);
}
int main()
{
    SetNoblocking(0);
    char buffer[1024];
   ssize_t n= read(0,buffer,sizeof(buffer)-1);
    if(n>0)
    {
        buffer[n-1]=0;
        std::cout<<buffer<<std::endl;
    }
    else if(n==0)
    {
        std::cout<<"Read to the end of the file!!"<<std::endl;
    }
    else 
    {
        if(errno==EWOULDBLOCK)
        std::cout<<"不是错误是非阻塞读！！做别的事"<<std::endl;
        else
        std::cout<<"Read error!!"<<std::endl;
    }
    return 0;
}